/**
 * Created by WANGBING15 on 2015/12/17.
 */


function dataTableMethod(dataTableId,ssx){
    dataTableId.dataTable({
        "bJQueryUI": false,
        'bPaginate': false, //是否分页
        "bRetrieve": false, //是否允许从新生成表格
        "bInfo": false, //显示表格的相关信息
        "bDestroy": true,
        "bServerSide": false,
        "bProcessing": true, //当处理大量数据时，显示进度，进度条等
        "bFilter": true, //搜索框
        "bLengthChange": false, //动态指定分页后每页显示的记录数
        "bSort": true, //排序
        "bStateSave": false, //缓存
        "sScrollX": "100%",
        "sScrollXInner": ssx,
        "bScrollCollapse": true,
        "sDom": '<![CDATA[fl<"top">rt<"bottom"ip><"clear">]]>',
        "oTableTools": {
            "aButtons": [ "copy", "xls","print" ],
            "sSwfPath": "../../resources/vendor/plugins/datatables/extensions/TableTools/swf/copy_csv_xls.swf"
        },
        "bRetrieve": true,
        language: {
            "sProcessing": "处理中...",
            "sLengthMenu": "显示 _MENU_ 项结果",
            "sZeroRecords": "没有匹配结果",
            "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
            "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
            "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
            "sInfoPostFix": "",
            "sSearch": "搜索:",
            "sUrl": "",
            "sEmptyTable": "表中数据为空",
            "sLoadingRecords": "载入中...",
            "sInfoThousands": ",",
            "oPaginate": {
                "sFirst": "首页",
                "sPrevious": "上页",
                "sNext": "下页",
                "sLast": "末页"
            },
            "oAria": {
                "sSortAscending": ": 以升序排列此列",
                "sSortDescending": ": 以降序排列此列"
            }
        }
    });
    $('.dataTables_filter input').attr("placeholder", "请输入...");
}

function datetimepickerMethod(dateId) {
    dateId.datetimepicker({
        prevText: '<i class="fa fa-chevron-left"></i>',
        nextText: '<i class="fa fa-chevron-right"></i>',
        timeFormat: 'HH:mm:ss',
        
        beforeShow: function (input, inst) {
            var newclass = 'admin-form';
            var themeClass = $(this).parents('.admin-form').attr('class');
            var smartpikr = inst.dpDiv.parent();
            if (!smartpikr.hasClass(themeClass)) {
                inst.dpDiv.wrap('<div class="' + themeClass + '"></div>');
            }
        }
    });
}

//日期加上天数后的新日期.
function AddDays(date,days){
    var nd = new Date(date);
    nd = nd.valueOf();
    nd = nd + days * 24 * 60 * 60 * 1000;
    nd = new Date(nd);
    var y = nd.getFullYear();
    var m = nd.getMonth()+1;
    var d = nd.getDate();
    if(m  <= 9) m = "0"+m;
    if(d <= 9) d = "0"+d;
    var cdate = y+"-"+m+"-"+d+" 00:00";
    return cdate;
}

function resetInput(){
    $("input[type!=hidden]").val("");
    $("select[id!=pageSize]").val("");
}
